﻿using M.Warehouse.API.Application.Command.WarehousesCommand;
using M.Warehouse.Domain;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.WarehousesHandlers
{
    public class WarehousesPlanShowCommandHandlers : IRequestHandler<WarehousesPlanShowCommand, List<Warehouses>>
    {
        private readonly IWarehouseWRepository _warehouseWRepository;
        public WarehousesPlanShowCommandHandlers(IWarehouseWRepository warehouseWRepository)
        {
            _warehouseWRepository = warehouseWRepository;
        }
        /// <summary>
        /// 显示仓库平面图
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<Warehouses>> Handle(WarehousesPlanShowCommand request, CancellationToken cancellationToken)
        {
            var warehousePlan=(await _warehouseWRepository.GetAllAsync()).Where(x=>x.ReservoirArea==request.ReservoirArea).ToList();
            return warehousePlan;
        }
    }
}
